package com.example.hello;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //设置隐藏头部标题栏
        ActionBar bar = getSupportActionBar();
        if(null != bar){
            bar.hide();
        }

        //获取账号和密码输入框组件对象
        final EditText accountET = findViewById(R.id.accountET);
        final EditText passwordET = findViewById(R.id.passwordET);
        //获取登录按钮对象
        Button loginBtn = findViewById(R.id.loginBtn);

        //给按钮添加点击监听事件
        loginBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //获取用户输入的账号密码
                String account = accountET.getText().toString();
                String password = passwordET.getText().toString();
                if (!account.isEmpty() && !password.isEmpty()){
                    //创建跳转界面意图对象
                    Intent intent = new Intent(MainActivity.this, UserCenterActivity.class);
                    //执行跳转
                    startActivity(intent);
                    return;
                }
                Toast.makeText(MainActivity.this, "账号或密码不能为空！", Toast.LENGTH_SHORT).show();

            }
        });



    }
}
